﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Root.master" AutoEventWireup="true" CodeFile="account.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="Server">
    <script src="../Scripts/toolbar.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        // <![CDATA[
        function OnkontrChanged(cbbKontr) {
            grid.GetEditor("DOG").PerformCallback(cbbKontr.GetValue().toString());
        }

        var command;
        function OnBeginCallback(s, e) {
            command = e.command;
        }
        function OnEndCallback(s, e) {
            if (command == "STARTDEL") {
                if (s.cpCancelDEL)
                    alert("The record can't be edit, reason: " + s.cpMessage);
            }
        }
        // ]]>
    </script>
    <div class="pageLabel">
        <dx:ASPxLabel ID="lbl_page" runat="server" Text="Список счетов" Font-Size="Medium" Theme="iOS">
        </dx:ASPxLabel>
    </div>
    <div style="float: left; margin-left: 10px; margin-right: 10px;">
        <table>
            <tr>
                <td>
                    <dx:ASPxDateEdit ID="dt1" runat="server" Width="90px" AllowNull="False" HelpText="Дата выписки с" HelpTextSettings-Position="Top"></dx:ASPxDateEdit>
                </td>
                <td>
                    <dx:ASPxDateEdit ID="dt2" runat="server" Width="90px" AllowNull="False" HelpText="Дата выписки по" HelpTextSettings-Position="Top"></dx:ASPxDateEdit>
                </td>
                <td valign="bottom" runat="server">
                    <dx:ASPxButton ID="btnGet" runat="server" Text="Загрузить" Theme="Office2010Silver">
                    </dx:ASPxButton>
                </td>
            </tr>
        </table>
        <br />
        <div>
            <dx:ASPxMenu ID="mMenu" runat="server" EnableViewState="False" EncodeHtml="False" SeparatorWidth="2px" BackColor="Transparent"
                SeparatorHeight="15px" ItemSpacing="1px">
                <SeparatorBackgroundImage ImageUrl="~\Images\shared\ToolBars\Office2003\SeparatorBackground.png" />
                <ClientSideEvents ItemClick="function(s, e) { MenuItemClick(e, grid); }" />
                <Items>
                    <dx:MenuItem Name="btn_Insert" Text="" ToolTip="Добавить запись" GroupName="grp_edit" BeginGroup="True">
                        <Image Url="~/Images/shared/edit_add.png">
                        </Image>
                    </dx:MenuItem>
                    <dx:MenuItem GroupName="grp_edit" Name="btn_edit" Text="" ToolTip="Редактировать запись">
                        <Image Url="~/Images/shared/edit.png" UrlDisabled="~/Images/shared/edit_disable.png">
                        </Image>
                    </dx:MenuItem>
                    <dx:MenuItem GroupName="grp_edit" Name="btn_Delete" Text="" ToolTip="Удалит запись">
                        <Image Url="~/Images/shared/editdelete.png" UrlDisabled="~/Images/shared/editdelete_disable.png">
                        </Image>
                    </dx:MenuItem>
                </Items>
            </dx:ASPxMenu>
        </div>
        <dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False"
            DataSourceID="ds_Schet" KeyFieldName="CODE" Width="100%"
            OnRowInserting="grid_RowInserting" OnCellEditorInitialize="grid_CellEditorInitialize">
            <Columns>
                <dx:GridViewDataTextColumn FieldName="CODE" ReadOnly="True" VisibleIndex="0" Caption="Код" Width="60px">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="SNOMER" VisibleIndex="1" Caption="Номер счета" Width="80px">
                    <PropertiesTextEdit Width="80px">
                    </PropertiesTextEdit>
                    <EditFormSettings VisibleIndex="0" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataDateColumn FieldName="SDATA" VisibleIndex="2" Caption="Дата выписки" Width="80px">
                    <PropertiesDateEdit Width="80px">
                    </PropertiesDateEdit>
                    <EditFormSettings VisibleIndex="2" />
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataComboBoxColumn FieldName="DOG" VisibleIndex="4" Caption="Договор №" Width="60px">
                    <PropertiesComboBox DataSourceID="ds_DOG" TextField="NOMDOG" ValueField="CODE" ValueType="System.Int32" Width="150px">
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="3" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTextColumn FieldName="NOTE" VisibleIndex="6" Caption="Примечание">
                    <PropertiesTextEdit Width="325px">
                    </PropertiesTextEdit>
                    <EditFormSettings ColumnSpan="2" VisibleIndex="4" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="Организация" FieldName="KONTRAGENT" VisibleIndex="3" Width="100px">
                    <PropertiesComboBox DataSourceID="ds_kontr" TextField="NAME" ValueField="CODE" ValueType="System.Int32" Width="150px">
                        <ClientSideEvents SelectedIndexChanged="function(s, e) { OnkontrChanged(s);}"
                            ButtonClick="function(s, e) { s.SetSelectedIndex(-1); grid.GetEditor('DOG').PerformCallback(-1); }" />
                        <Buttons>
                            <dx:EditButton Text="X" ToolTip="очистить">
                            </dx:EditButton>
                        </Buttons>
                    </PropertiesComboBox>
                    <EditFormSettings VisibleIndex="1" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataCheckColumn Caption="Ш" ToolTip="Создан на основании шаблона" FieldName="AUTO" VisibleIndex="5" Width="20px" HeaderStyle-HorizontalAlign="Center">
                    <PropertiesCheckEdit ValueChecked="1" ValueType="System.Byte" ValueUnchecked="0">
                    </PropertiesCheckEdit>
                    <EditFormSettings Visible="False" />

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                </dx:GridViewDataCheckColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" ConfirmDelete="True" EnableCustomizationWindow="true" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
            <SettingsPager AlwaysShowPager="True">
                <PageSizeItemSettings Visible="True">
                </PageSizeItemSettings>
            </SettingsPager>
            <SettingsEditing Mode="PopupEditForm" />
            <SettingsDetail AllowOnlyOneMasterRowExpanded="True" ExportMode="Expanded" ShowDetailRow="True" />
            <SettingsPopup>
                <EditForm HorizontalAlign="LeftSides" Modal="True" />
            </SettingsPopup>
            <Templates>
                <DetailRow>
                    <div align="left">
                        <b>Спецификация счета</b>
                        <div>

                            <dx:ASPxMenu ID="mMenu" runat="server" EnableViewState="False" EncodeHtml="False" SeparatorWidth="2px" BackColor="Transparent"
                                SeparatorHeight="15px" ItemSpacing="1px">
                                <SeparatorBackgroundImage ImageUrl="~\Images\shared\ToolBars\Office2003\SeparatorBackground.png" />
                                <ClientSideEvents ItemClick="function(s, e) { MenuItemClick(e, grdShcetSpec); }" />
                                <Items>
                                    <dx:MenuItem Name="btn_Insert" Text="" ToolTip="Добавить запись" GroupName="grp_edit" BeginGroup="True">
                                        <Image Url="~/Images/shared/edit_add.png">
                                        </Image>
                                    </dx:MenuItem>
                                    <dx:MenuItem GroupName="grp_edit" Name="btn_edit" Text="" ToolTip="Редактировать запись">
                                        <Image Url="~/Images/shared/edit.png">
                                        </Image>
                                    </dx:MenuItem>
                                    <dx:MenuItem GroupName="grp_edit" Name="btn_Delete" Text="" ToolTip="Удалит запись">
                                        <Image Url="~/Images/shared/editdelete.png">
                                        </Image>
                                    </dx:MenuItem>
                                </Items>
                            </dx:ASPxMenu>
                        </div>
                        <dx:ASPxGridView ID="grdShcetSpec" ClientInstanceName="grdShcetSpec" runat="server" AutoGenerateColumns="False" DataSourceID="ds_SchetSpec"
                            KeyFieldName="CODE"
                            OnBeforePerformDataSelect="grdShcetSpec_BeforePerformDataSelect"
                            OnRowInserting="grdShcetSpec_RowInserting" Theme="DevEx" OnHtmlDataCellPrepared="grdShcetSpec_HtmlDataCellPrepared">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="CODE" ReadOnly="True" VisibleIndex="0" Caption="Код" Width="60px">
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="SCHET" VisibleIndex="1" Caption="Счет" Visible="False" Width="80px">
                                    <EditFormSettings Visible="False" />
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataComboBoxColumn Caption="Услуга" FieldName="SERVICES" VisibleIndex="2" Width="150px">
                                    <PropertiesComboBox DataSourceID="ds_Services" TextField="NAME" ValueField="CODE" ValueType="System.Int32">
                                    </PropertiesComboBox>
                                </dx:GridViewDataComboBoxColumn>
                                <dx:GridViewDataTextColumn FieldName="TARIF" VisibleIndex="3" Caption="Тариф" Width="80px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="QUANTITY" VisibleIndex="4" Caption="Кол-во" Width="80px">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Name="SUMMA" Caption="Сумма" VisibleIndex="5" Width="80px" CellStyle-HorizontalAlign="Right">
                                    <EditFormSettings Visible="False" />
                                    <DataItemTemplate>
                                        
                                    </DataItemTemplate>
                                    <CellStyle HorizontalAlign="Right">
                                    </CellStyle>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <SettingsPager Visible="False">
                            </SettingsPager>
                            <SettingsBehavior AllowFocusedRow="True" ConfirmDelete="True" EnableCustomizationWindow="true" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
                        </dx:ASPxGridView>
                </DetailRow>
            </Templates>
        </dx:ASPxGridView>
    </div>
    <asp:EntityDataSource ID="ds_Schet" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="SCHET" Where="it.SDATA &gt;= @SDATA1 and it.SDATA &lt;= @SDATA2">
        <WhereParameters>
            <asp:ControlParameter ControlID="dt1" DbType="Date" Name="SDATA1" PropertyName="Value" />
            <asp:ControlParameter ControlID="dt2" DbType="Date" Name="SDATA2" PropertyName="Value" />
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="ds_SchetSpec" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="SCHETSPEC" AutoGenerateWhereClause="True" Where="">
        <WhereParameters>
            <asp:SessionParameter DbType="Int32" Name="SCHET" SessionField="SCHET" />
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="ds_Services" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="SERVICES">
    </asp:EntityDataSource>
        <asp:EntityDataSource ID="ds_kontr" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="KONTRAGENT" Select="it.[CODE], it.[NAME]">
        </asp:EntityDataSource>
    <asp:EntityDataSource ID="ds_DOG" runat="server" ConnectionString="name=RegistRar" DefaultContainerName="RegistRar" EnableFlattening="False" EntitySetName="DOG"></asp:EntityDataSource>
</asp:Content>

